import storage from "./storage";

export function setToken(token) {
  storage.setItem("token", token);
}

export function getToken() {
  return storage.getItem("token") || "";
}

export function isLogin() {
  return Boolean(getToken());
}

export function clearToken() {
  storage.removeItem("token");
  return true;
}

export function getCurrentAuthority() {
  return isLogin() ? ["admin"] : [];
}

export function check(authority) {
  const current = getCurrentAuthority();
  return current.some(item => authority.includes(item));
}
